home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / LAHEY386.ARC / GETTIM.ASM < prev    next >
Assembly Source File  |  1988-09-06  |  3KB  |  99 lines

  1. ;
  2. ; GETTIM.ASM
  3. ;
  4. ; Author:    M. Steven Baker
  5. ; Date:        August 27, 1988
  6. ;
  7. ; a GETTIM subroutine for LAHEY F77/32 bit
  8. ; must assemble with MASM 5.x or higher
  9. ; based on SAMPLE.ASM code from LAHEY supplemental disk
  10. ; FORTRAN calling convention with INTEGER*4 arguments
  11. ;    CALL GETTIM(ihr,imin,isec,i100)
  12.  
  13. .386    ; required to generate 32-bit code/data
  14.  
  15. ; It is very important when linking to F77L-EM/32 program units that any data
  16. ; segments your assembly code uses have their class name as 'DATA' in order
  17. ; to link correctly.  In addition, you must also use the GROUP directive 
  18. ; to include the data in group DGROUP.  DS and ES are set to DGROUP by the 
  19. ; FORTRAN code, and must be set that way on return.  Your code segment must
  20. ; also be included in the group CGROUP, and include the directive:
  21. ; ASSUME DS:DGROUP, CS:CGROUP
  22.  
  23. data    segment    dword public 'DATA'
  24. dgroup    group    data
  25.  
  26. data    ends
  27. ;
  28. ; Any code segments should have a class name of 'CODE'.
  29. ;
  30. excode    segment    dword public 'CODE'
  31. cgroup    group    excode
  32. assume    cs:cgroup, ds:dgroup
  33. ;
  34. ; The procedure names must be declared public to be addressable by
  35. ; other modules.
  36. ;
  37. public    GETTIM
  38.  
  39. GETTIM    proc    near
  40. ;
  41. ; Upon entry to any subroutine, F77L-EM/32 has pushed addresses of
  42. ; each argument onto the stack.  In the calling program,
  43. ; 'gettim' was defined as a simple subroutine; 
  44. ; When all arguments have been dealt with, 
  45. ; F77L-EM/32 issues a near call to the named routine.
  46. ;
  47. ; log4 = example( int2, int4, int2a, int2a(3), dp, cmpx )
  48. ;          arg1  arg2  arg3     arg4   arg5 arg6
  49. ;
  50. ;    push    ebp        ; always do this... if EBP/ESP are used
  51. ;    mov    ebp, esp    ; and this (ebp must be preserved)
  52. ;
  53. ; The arguments are pushed right to left; thus, the first argument
  54. ; is closest to ebp.  At this point, the stack contains:
  55. ;
  56. ;    offset of argn
  57. ;         ...
  58. ;    offset of arg1 = IHR
  59. ;    return code offset  (EIP) }-- four byte address from near call
  60. ;    saved ebp    <-- ebp, esp
  61. ;
  62. ; The first argument address is now 8 bytes from ebp, referenced at [ebp+8].
  63. ; Note that the minimum argument displacement is 8 for subroutines and 12
  64. ; for functions.
  65. ;
  66. ;    CALL GETTIM(ihr,imin,isec,i100)
  67. ;
  68.     mov    ah,2ch        ;DOS Get Time function
  69.     int    21h        ;returns CH=hour,   CL=minute
  70.                 ;        DH =second DL=hundredths
  71.     mov    eax,ss:[esp+4]
  72.     mov    dword ptr [eax],0    ;zero value
  73.     mov    [eax],ch        ;set minutes
  74. ;
  75.     mov    eax,ss:[esp+8]
  76.     mov    dword ptr [eax],0    ;zero value
  77.     mov    [eax],cl        ;set minutes
  78. ;
  79.     mov    eax,ss:[esp+0ch]
  80.     mov    dword ptr [eax],0    ;zero value
  81.     mov    [eax],dh        ;set seconds
  82. ;
  83.     mov    eax,ss:[esp+10h]
  84.     mov    dword ptr [eax],0    ;zero value
  85.     mov    [eax],dl        ;set 1/100 seconds
  86. ;
  87.     ret
  88. GETTIM    endp
  89.  
  90.  
  91.  
  92. excode    ends
  93.  
  94.     end
  95. ;
  96. ; Do not put any label name or expression after the end statement!  This
  97. ; defines a program entry point, which has already been defined by the
  98. ; Fortran MAIN module.
  99.